package com.btl.service.ai.support.input.common.parse.strategy;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;

@Getter
public enum FileTypeEnum {

    TEXT(List.of("text/plain", "text/csv", "text/markdown", "text/x-markdown")),
    PDF(List.of("application/pdf")),
    POI(List.of(
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "application/vnd.ms-excel"
    )),
    HTML(List.of("text/html"));

    private final List<String> contentTypes;

    FileTypeEnum(List<String> contentTypes) {
        this.contentTypes = contentTypes;
    }

    public static FileTypeEnum fromContentType(String contentType) {
        return Arrays.stream(FileTypeEnum.values())
                .filter(e -> e.contentTypes.stream()
                        .anyMatch(ct -> ct.equalsIgnoreCase(contentType)))
                .findFirst()
                .orElse(FileTypeEnum.TEXT);
    }
}